package mywindow

import (
	"github.com/wailsapp/wails/v3/pkg/application"
	"github.com/wailsapp/wails/v3/pkg/events"
)

var WindowName = "ToolBar"

// NewToolsWindow 截图功能也可以提取成一个单独程序，设计screenshot，robotgo库的使用
func NewToolsWindow(app *application.App) *application.WebviewWindow {
	Window := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
		Title:           WindowName,
		Name:            WindowName,
		Width:           600,
		Height:          400,
		AlwaysOnTop:     false,
		Hidden:          true,
		DisableResize:   false,
		Frameless:       false,
		InitialPosition: application.WindowCentered,
		URL:             "index.html",
	})
	Window.SetMaxSize(800, 600)
	Window.RegisterHook(events.Common.WindowLostFocus, func(e *application.WindowEvent) {
		Window.Hide()
	})
	Window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
		e.Cancel()
		Window.Hide()
	})
	return Window
}
